How to write a unique dictionary within dictionary with list as keys to a csv file